package com.xiaoniu.forum.common.utils;

import com.xiaoniu.forum.renren.common.exception.RRException;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

@Component
public class TokenUtils {
    @Autowired
    private  JwtUtils jwtUtils;
    public boolean checkToken(String token){
        Claims claims = jwtUtils.getClaimByToken(token);
        if(claims == null || jwtUtils.isTokenExpired(claims.getExpiration())){
            return true;
        }
        return false;
    }

    public String getMemberId(String token){
        Claims claims = jwtUtils.getClaimByToken(token);
        return claims.getSubject();
    }
}
